﻿
@section scripts {
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
<script src="https://unpkg.com/element-plus/dist/index.full.min.js"></script>

<script>
    const { createApp, ref } = Vue;

    const app = createApp({
        setup() {
            const formData = ref({
                first_kind_id: '',
                first_kind_name: '',
                first_kind_salary_id: '',
                first_kind_sale_id: ''
            });

            const submitForm = async () => {
                try {
                    const response = await axios.post(
        '@Url.Action("InsertApi", "Config")', // 生成正确的 URL
        formData.value,
        { headers: { "Content-Type": "application/json" } }
    );

                    if (response.data.success) {
                        ElMessage.success('添加成功');
                        //window.location.href = '@Url.Action("Index", "Config")';
                    } else {
                        ElMessage.error('添加失败: ' + response.data.message);
                    }
                } catch (error) {
                    console.error('请求错误:', error);
                    ElMessage.error('服务器错误，请重试');
                }
            };

            return {
                formData,
                submitForm
            };
        }
    });

    app.use(ElementPlus);
    app.mount('#vue-app');
</script>
}

<div id="vue-app">
    <div class="config-file-first-kind">
        <!-- 面包屑导航 -->
        <div class="breadcrumb">
            <font color="black">
                您正在做的业务是：人力资源--客户化设置--人力资源档案管理设置--I级机构设置--I级机构添加
            </font>
        </div>

        <!-- Element UI表单 -->
        <el-form :model="formData" label-width="120px">
            <el-form-item label="I级机构编号">
                <el-input v-model="formData.first_kind_id"></el-input>
            </el-form-item>

            <el-form-item label="I级机构名称">
                <el-input v-model="formData.first_kind_name"></el-input>
            </el-form-item>

            <el-form-item label="薪酬发放责任人编号">
                <el-input v-model="formData.first_kind_salary_id" type="textarea" :rows="4"></el-input>
            </el-form-item>

            <el-form-item label="销售责任人编号">
                <el-input v-model="formData.first_kind_sale_id" type="textarea" :rows="4"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" v-on:click ="submitForm">提交</el-button>
                <el-button v-on:click="window.history.back()">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</div>